<?php


/**
 * 获取专题列表
 * @access  public
 * @return void
 */
function get_sql_topic_list(){
	/* 查询条件 */
	$filter['sort_by']    	=	empty($_REQUEST['sort_by']) ? 'topic_id' : trim($_REQUEST['sort_by']);
	$filter['sort_order'] 	= 	empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);

	$sql 					= 	"SELECT * FROM " . 'ybr_topic' . " ORDER BY $filter[sort_by] $filter[sort_order]";	

	return $sql;
}

/**
 * 根据过滤条件获得排序的标记
 *
 * @access  public
 * @param   array   $filter
 * @return  array
 */
function sort_flag($filter){
    $flag['tag']    	= 	'sort_' . preg_replace('/^.*\./', '', $filter['sort_by']);
    $flag['img']    	= 	'<img src="images/' . ($filter['sort_order'] == "DESC" ? 'sort_desc.gif' : 'sort_asc.gif') . '"/>';
    return $flag;
}


/**
 * 取得品牌列表
 * @return array 品牌列表 id => name
 */
function get_brand_list(){
    $sql 		= 	'SELECT brand_id, brand_name FROM ' . 'ybr_brand' . ' ORDER BY sort_order';
    $res 		= 	M()->query($sql);

    $brand_list = 	array();
    foreach ($res AS $row){
        $brand_list[$row['brand_id']] = addslashes($row['brand_name']);
    }
    return $brand_list;
}
